﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Jumpton.SFA.Server.BusinessRule.System;
using Jumpton.Persistent;
using Jumpton.SFA.Server.Entity;
public partial class System_Financial_Month_Maintain :PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGrid();
        }
    }
    protected void BindGrid()
    {
        gvChannelType.DataSource = new FinancialMonthManager().GetByDate(txtDate.Value,MyStateManager.DomainID);
        gvChannelType.DataBind();

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        FinancialMonthManager.CreateFinancialMonth( MyStateManager.Name,MyStateManager.DomainID);
        BindGrid();
    }
    protected void gvChannelType_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        object oID = e.CommandArgument;
        if (e.CommandName == "EditStatus" && oID != null)
        {
            ObjectRow obj= ObjectRow.Load(typeof(Financial_Month), "Date='" + oID.ToString() + "'");
            if (obj != null)
            {
                Financial_Month fmonth = (Financial_Month)obj;
                if (fmonth.Status == "1")
                {
                    fmonth.Status = "0";
                }
                else
                {
                    fmonth.Status = "1";
                }
                fmonth.Save();
                BindGrid();
            }
        }
    }
    protected void gvChannelType_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvChannelType.PageIndex = e.NewPageIndex;
        BindGrid();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        BindGrid();
    }
}
